package sysinit

import (
	"object/go_cms/common"
	"object/go_cms/models"
	"time"
)

//获取系统配置信息
func GetConfig(key string) (out interface{}) {
	out = ""
	cache := common.Caches{}
	configList := cache.GetFileCache("config")
	if configList == nil || configList == "" {
		cm := models.ConfigModels{}
		configList, _ = cm.Query(make(map[string]interface{}))
		cache.SetFileCache("config", configList, 2000*time.Second)
	}
	//类型转换，通过断言实现类型转换
	confs, _ := configList.([]models.Config)
	for i := 0; i < len(confs); i++ {
		if confs[i].Name == key {
			out = confs[i].Value
			break
		}
	}
	return
}
